<template>
	<view class="order-container">
		<u-navbar :border-bottom="false" :is-back="false" title-color="#FFFFFF" title=" " :background="nav_background">
			<view class="tabs-wrapper">
				<block v-for="(item, index) in list" :key="index">
					<view v-if="$accessCheck($Access[item.access])" @click="tabChange(index)" :class="[tab_current === index ? 'tab-active' : '']" class="tab-item">
						{{ item.label }}
					</view>
				</block>
			</view>
		</u-navbar>
		<view class="order-content">
			<view v-if="tab_current === 0 && $accessCheck($Access['orderQuery'])">
				<OrderList :customerData="customerData" :shopData="shopData" :paymentData="paymentData" :customerTypeData="customerTypeData" :staffData="staffData"></OrderList>
			</view>
			<view v-else-if="tab_current === 1 && $accessCheck($Access['ReturnWarehousingOrder'])"><OrderReturn :shopData="shopData" :staffData="staffData"></OrderReturn></view>
			<view v-else class="empty-view"><u-empty text="暂无权限" mode="order"></u-empty></view>
		</view>
		<!-- 底部tabbar -->
		<Tabbar v-model="tabbar_current"></Tabbar>
	</view>
</template>

<script>
import { mapActions } from 'vuex';
import OrderReturn from './OrderReturn.vue';
import OrderList from './OrderList.vue';
export default {
	components: {
		OrderReturn,
		OrderList
	},
	data() {
		return {
			tabbar_current: 1,
			nav_background: {
				backgroundColor: '#FB5904'
			},
			tab_current: 0, // 页面current 0，订单，1，退货单
			list: [
				{
					label: '订单管理',
					access: 'orderQuery'
				},
				{
					label: '退货单据',
					access: 'ReturnWarehousingOrder'
				}
			],
			customerData: '',
			shopData: '',
			paymentData: '',
			staffData: '',
			customerTypeData: '',
			search_data: {}
		};
	},
	onLoad() {
		if (!this.$store.state.hasLogin) {
			this.logout();
		}
	},
	methods: {
		...mapActions({
			logout: 'logout'
		}),
		tabChange(index) {
			this.tab_current = index;
		}
	}
};
</script>

<style scoped lang="scss">
.order-container {
	background-color: #f8f8f8;
	min-height: 100vh;
}

.order-content {
	padding-top: 10rpx;
}

.tabs-wrapper {
	display: flex;
	width: 320rpx;
	height: 72rpx;
	font-size: 28rpx;
	background-color: rgba(255, 255, 255, 0.2);
	position: absolute;
	/* #ifdef MP*/
	right: 20rpx;
	/*#endif*/
	/* #ifdef H5 || APP-PLUS*/
	left: 50%;
	transform: translateX(-50%);
	/*#endif*/
	border-radius: 36rpx;
	overflow: hidden;
	box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
	
	.tab-item {
		flex: 1;
		text-align: center;
		line-height: 72rpx;
		color: #ffffff;
		font-weight: 400;
		transition: all 0.3s;
	}

	.tab-active {
		background-color: #ffffff;
		color: #FB5904;
		font-weight: 500;
		font-size: 28rpx;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
	}
}

.empty-view {
	padding-top: 200rpx;
}
</style>
